﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KingRoad.EPM.SafetyManagementBLL.Domain;
using KingRoad.EPM.SafetyManagementEntity.Model;
using Unis.Framework.Core.Utility;

using ScmCostActualService;
using ScmCostActualmainService;
using System.Data;


namespace KingRoad.EPM.SafetyManagementBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/2/6 13:53:28
    /// </summary> 
    public class ScmCostactualmainUIRule
    {
        private readonly IScmCostactualmainService _scmCostactualmainService;
        private IScmCostactualService _scmCostactualService;

        public ScmCostactualmainUIRule() { }

        /// <summary> 
        /// construct function... 
        /// </summary> 
        public ScmCostactualmainUIRule(IScmCostactualmainService scmCostactualmainService)
        {
            _scmCostactualmainService = scmCostactualmainService;
            _scmCostactualService = new ScmCostactualService();
        }


        /// <summary>
        /// 获取费用使用信息
        /// </summary>
        /// <returns></returns>
        public List<ScmCostactualmainInfo> GetAllCostactualmain()
        {
            var list = _scmCostactualmainService.GetEntityList();
            return list;
        }
        /// <summary>
        /// 根据条件查询费用使用信息
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<ScmCostactualmainInfo> GetAllCostactualmainForPage(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition)
        {
            var list = _scmCostactualmainService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition);
            return list;
        }
        /// <summary>
        /// 根据id获取费用使用信息
        /// </summary>
        /// <returns></returns>
        public ScmCostactualmainInfo GetCostactualmainById(Guid id)
        {
            var spminfo = _scmCostactualmainService.GetEntityById(id);
            return spminfo;
        }
        /// <summary>
        /// 添加费用使用信息
        /// </summary>
        /// <returns></returns>
        public int AddCostactualmain(ScmCostactualmainInfo AddEntity)
        {
            return _scmCostactualmainService.InsertEntity(AddEntity);
        }
        /// <summary>
        /// 修改费用使用信息
        /// </summary>
        /// <returns></returns>
        public int UpdateCostActualmain(ScmCostactualmainInfo UpdateEntity)
        {
            return _scmCostactualmainService.UpdateEntity(UpdateEntity);
        }
        /// <summary>
        /// 删除费用使用信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteCostactualmain(string id)
        {
            var cp = _scmCostactualService.DeleteEntityByStringFID(id);
            return _scmCostactualmainService.DeleteEntityByStringID(id);
        }

        /// <summary>
        /// 根据Fid获取费用使用子表信息
        /// </summary>
        /// <returns></returns>
        public List<ScmCostactualInfo> GetCostactualByFId(Guid fid)
        {

            var list = _scmCostactualService.GetEntityList(" cam_id = '" + fid + "'");
            return list;
        }
        /// <summary>
        /// 添加费用使用子表信息
        /// </summary>
        /// <returns></returns>
        public int AddCostactual(ScmCostactualInfo AddEntity)
        {
            return _scmCostactualService.InsertEntity(AddEntity);
        }
        /// <summary>
        /// 删除费用使用子表信息
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        public int DeleteCostactualByFId(string fid)
        {
            return _scmCostactualService.DeleteEntityByStringFID(fid);
        }
        /// <summary>
        /// 获取计量台账信息
        /// </summary>
        /// 
        /// <returns></returns>
        public DataTable GetCostLedger(DateTime? starttime,DateTime? endtime)
        {
            return _scmCostactualmainService.GetCostLedger(starttime,endtime);
        }
        /// <summary>
        /// 删除费用使用信息(批量删除)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteCostActualmainMulti(string id)
        {
            var cp = _scmCostactualService.DeleteEntityByMultiStringID(id);
            return _scmCostactualmainService.DeleteEntityByMultiStringID(id);
        }
    }
}

